package io.bhex.sdk;

import android.content.Context;
import android.util.DisplayMetrics;

import com.facebook.stetho.common.LogUtil;

import io.bhex.baselib.utils.DebugLog;

/**
 * Created by BHEX.
 * User: gdy
 * Date: 2020/3/31
 * Time: 0:32
 */
public class PhoneUtil {

    private static PhoneUtil _instance;

    public int dip;
    public float density;
    public int widthDip;
    public int heightDip;
    public int widthPixel;
    public int heightPixel;

    private PhoneUtil(){

    }

    public static  PhoneUtil getInstance(){
        if(_instance==null){
            _instance = new PhoneUtil();
        }
        return _instance;
    }
    /**
     * 初始化手机设备
     */
    public void initDevice(Context context){
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        density = dm.density;

        dip = dm.densityDpi;

        widthPixel = dm.widthPixels;
        //heightPixel = dm.widthPixels;
        heightPixel = dm.heightPixels;
        widthDip = (int)(widthPixel/density);
        heightDip = (int)(heightPixel/density);
        DebugLog.d("PhoneUtil==>:","widthPixel=="+widthPixel+"=heightPixel="+heightPixel+"=dip="+dip+"=density="+density);
        DebugLog.d("PhoneUtil==>:","widthDip=="+widthDip+"=heightDip="+heightDip);

    }
}
